package com.appleyk.spring.security.init;

import com.appleyk.spring.security.config.ApplicationConfig;
import com.appleyk.spring.security.config.WebConfig;
import com.appleyk.spring.security.config.WebSecurityConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * <p>越努力，越幸运</p>
 * 加载Spring容器
 * @author appleyk
 * @version V.0.1.1
 * @blob https://blog.csdn.net/appleyk
 * @date created on  8:19 下午 2021/1/4
 */
public class WebMvcApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    /**
     * 将配置类中的bean加载到Spring容器中
     * ApplicationConfig相当于applicationContext.xml
     * WebSecurityConfig相当于spring-security.xml
     */
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{ApplicationConfig.class, WebSecurityConfig.class};
    }

    // servletContext,相当于spring-mvc.xml
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{WebConfig.class};
    }

    // 相当于之前web.xml中的 url-mapping
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}
